<?php
/**
 * LogExceptionReporter class definition
 *   
 * @author Sean Crystal <seancrystal@gmail.com>
 * @package MutantVole
 */
require_once 'interfaces/iExceptionReporter.php';

/**
 * Reports exceptions to a log file
 * @package MutantVole
 * @subpackage Exceptions
 */   
class LogExceptionReporter implements iExceptionReporter {
	/**
     * Report an exception to the log
	 * @param Exception $e
	 */  	
	public function ReportException(Exception $e) 	{
		$message = $this->FormatException($e);

		Logger::Write($message);
	}
	
	/**
     * Formats an exception output for a text file
	 * @param Exception $e
	 * @return string
	 */   	
	protected function FormatException(Exception $e) {
		$message  = date('Y-m-d H:i:s') .'  Uncaught '. get_class($e) .': '. $e->getMessage() ."\n";
		$message .= $e->getTraceAsString();
		$message .= "\n\n";
		
		return $message;
	}
}

?>